home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / grafik / converter / limbo4.0 / src / 3d / mapop.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-16  |  18.6 KB  |  574 lines

  1. #include "includes.h"
  2.  
  3. /**************************************|****************************************
  4. Routine   : Map2BitMap
  5. Input  par: BitMap *SrcImg    (Pointer to the source image to copy.)
  6.             BitMap *DstImg    (Pointer to the destination image.)
  7.             int XStart        (The x position in the source image to start
  8.                                copying from.)
  9.             int YStart        (The y position in the source image to start
  10.                                copying from.)
  11. Output par: None
  12. Function  : Copies a part of a BitMap to a new BitMap.
  13. ***************************************|***************************************/
  14.  
  15.  void Map2BitMap(BitMap *SrcImg,BitMap *DstImg,int XStart,int YStart)
  16.   {
  17.    register unsigned int x,y;
  18.    const unsigned int Sizex=DstImg->XSize;
  19.    const unsigned int Sizey=DstImg->YSize;
  20.  
  21.    if (SrcImg->ImgType!=DstImg->ImgType) 
  22.    ErrorHandler(WRONG_FORMAT,"Images not of the same type");
  23.    for(x=0;x<Sizex;x++)    
  24.    for(y=0;y<Sizey;y++) DstImg->Map[x][y]=SrcImg->Map[XStart+x][YStart+y];
  25.   }
  26.  
  27. /**************************************|****************************************
  28. Routine   : BitMap2Map
  29. Input  par: BitMap *SrcImg      (Pointer to the bitmap to copy.)
  30.             BitMap *DstImg      (Pointer to the image to copy the source image
  31.                                  into.)
  32.             int XStart,YStart   (The x and y location in the destination image
  33.                                  to copy the source image into.)
  34. Output par: None
  35. Function  : Copies a the source bitmap into the specified location of the
  36.             destination bitmap.
  37. ***************************************|***************************************/
  38.  
  39.  void BitMap2Map(BitMap *SrcImg,BitMap *DstImg,int XStart,int YStart)
  40.   {
  41.    register unsigned int x,y;
  42.    const unsigned int Sizex=SrcImg->XSize;
  43.    const unsigned int Sizey=SrcImg->YSize;
  44.  
  45.    if (SrcImg->ImgType!=DstImg->ImgType) 
  46.    ErrorHandler(WRONG_FORMAT,"Images not of the same type");
  47.    for(x=0;x<Sizex;x++)     
  48.    for(y=0;y<Sizey;y++) DstImg->Map[XStart+x][YStart+y]=SrcImg->Map[x][y];
  49.   }
  50.  
  51. /**************************************|****************************************
  52. Routine   : Map3D2BitMap3D
  53. Input  par: BitMap3D *SrcImg (Pointer to the source image to copy.)
  54.             BitMap3D *DstImg (Pointer to the destination image.)
  55.             int XStart       (The x position in the source image to start
  56.                               copying from.)
  57.             int YStart       (The y position in the source image to start
  58.                               copying from.)
  59. Output par: None
  60. Function  : Copies a part of a BitMap3D to a new BitMap3D. Analog to Map2BitMap
  61. ***************************************|***************************************/
  62.  
  63.  void Map3D2BitMap3D(BitMap3D *SrcImg,BitMap3D *DstImg,int XStart,int YStart,int ZStart)
  64.   {
  65.    register unsigned int x,y,z;
  66.    const unsigned int Sizex=DstImg->XSize;
  67.    const unsigned int Sizey=DstImg->YSize;
  68.    const unsigned int Sizez=DstImg->ZSize;
  69.  
  70.    if (SrcImg->ImgType!=DstImg->ImgType) 
  71.    ErrorHandler(WRONG_FORMAT,"Images not of the same type");
  72.    for(x=0;x<Sizex;x++)    
  73.    for(y=0;y<Sizey;y++)
  74.    for(z=0;z<Sizez;z++)
  75.    DstImg->Map[x][y][z]=SrcImg->Map[XStart+x][YStart+y][ZStart+z];
  76.   }
  77.  
  78. /**************************************|****************************************
  79. Routine   : BitMap3D2Map3D
  80. Input  par: BitMap3D *SrcImg    (Pointer to the bitmap to copy.)
  81.             BitMap3D *DstImg    (Pointer to the image to copy the source image
  82.                                  into.)
  83.             int XStart,YStart   (The x and y location in the destination image
  84.                                  to copy the source image into.)
  85. Output par: None
  86. Function  : Copies a the source 3D bitmap into the specified location of the
  87.             destination bitmap. Analog to BitMap2Map
  88. ***************************************|***************************************/
  89.  
  90.  void BitMap3D2Map3D(BitMap3D *SrcImg,BitMap3D *DstImg,int XStart,int YStart,int ZStart)
  91.   {
  92.    register unsigned int x,y,z;
  93.    const unsigned int Sizex=SrcImg->XSize;
  94.    const unsigned int Sizey=SrcImg->YSize;
  95.    const unsigned int Sizez=SrcImg->ZSize;
  96.  
  97.    if (SrcImg->ImgType!=DstImg->ImgType) 
  98.    ErrorHandler(WRONG_FORMAT,"Images not of the same type");
  99.  
  100.    for(x=0;x<Sizex;x++)     
  101.    for(y=0;y<Sizey;y++)
  102.    for(z=0;z<Sizez;z++) 
  103.    DstImg->Map[XStart+x][YStart+y][ZStart+z]=SrcImg->Map[x][y][z];
  104.   }
  105.  
  106. /**************************************|****************************************
  107. Routine   : CopyBitMap3D
  108. Input  par: BitMap3D *SrcImg (source image to copy)
  109.             BitMap3D *DstImg (dest to copy to)
  110. Output par: none
  111. Function  : Copies a 3d bitmap to another 3d bitmap.
  112. ***************************************|***************************************/
  113.  
  114.  void CopyBitMap3D(BitMap3D *SrcImg,BitMap3D *DstImg)
  115.   {
  116.    register unsigned int x,y,z;
  117.    const unsigned int Sizex=DstImg->XSize;
  118.    const unsigned int Sizey=DstImg->YSize;
  119.    const unsigned int Sizez=DstImg->ZSize;
  120.  
  121.    if (SrcImg->ImgType!=DstImg->ImgType) 
  122.    ErrorHandler(WRONG_FORMAT,"Images not of the same type");
  123.  
  124.    for(x=0;x<Sizex;x++)    
  125.    for(y=0;y<Sizey;y++)
  126.    for(z=0;z<Sizez;z++) DstImg->Map[x][y][z]=SrcImg->Map[x][y][z];
  127.   }
  128.  
  129. /**************************************|****************************************
  130. Routine   : Frame2BitMap
  131. Input  par: BitMap3D *SrcImg (3d bitmap from where a frame must be extracted)
  132.             int z            (the number of the frame to be extracted)
  133.             BitMap *DstImg   (2d bitmap to copy to)
  134. Output par: none
  135. Function  : Copies a single frame of a 3d image to a 2d image.
  136. ***************************************|***************************************/
  137.  
  138.  void Frame2BitMap(BitMap3D *SrcImg,int z,BitMap *DstImg)
  139.   {
  140.    register unsigned int x,y;
  141.    if (SrcImg->ImgType!=DstImg->ImgType) 
  142.    ErrorHandler(WRONG_FORMAT,"Images not of the same type");
  143.    for(x=0;x<DstImg->XSize;x++)    
  144.    for(y=0;y<DstImg->YSize;y++) DstImg->Map[x][y]=SrcImg->Map[x][y][z];
  145.   }
  146.  
  147. /**************************************|****************************************
  148. Routine   : BitMap2Frame
  149. Input  par: BitMap *SrcImg   (2d bitmap frame)
  150.             BitMap3D *DstImg (3d bitmap image)
  151.             int z            (frame number of the 3d sequence)
  152. Output par: none
  153. Function  : Copies a 2d frame into a 3d bitmap.
  154. ***************************************|***************************************/
  155.  
  156.  void BitMap2Frame(BitMap *SrcImg,BitMap3D *DstImg,int z)
  157.   {
  158.    register unsigned int x,y;
  159.    if (SrcImg->ImgType!=DstImg->ImgType) 
  160.    ErrorHandler(WRONG_FORMAT,"Images not of the same type");
  161.    for(x=0;x<DstImg->XSize;x++)    
  162.    for(y=0;y<DstImg->YSize;y++) DstImg->Map[x][y][z]=SrcImg->Map[x][y];
  163.   }
  164.  
  165. /**************************************|****************************************
  166. Routine   : T_CScaleAndLShift3D
  167. Input  par: BitMap3D *SrcImg (3d bitmap image to be shifted and scaled)
  168.             float Scale      (contrast scale parameter , i.e. alpha)
  169.             int Shift        (luminance shift parameter, i.e. deltag)
  170. Output par: none
  171. Function  : Takes a 3d image and scale it (*) with Mul and the shifts it with (+)
  172.             Shift. The order of the * and + is important!
  173. ***************************************|***************************************/
  174.  
  175.  void T_CScaleAndLShift3D(BitMap3D *SrcImg,float Scale,int Shift)
  176.   {
  177.    register unsigned int x=SrcImg->XSize,y,z;
  178.    register int Val;
  179.    
  180.    while(x--)      
  181.     {
  182.      y=SrcImg->YSize;
  183.      while(y--)        
  184.       {
  185.        z=SrcImg->ZSize;
  186.        while(z--)
  187.         {
  188.          Val = (int)(SrcImg->Map[x][y][z]*Scale+0.5)+Shift;
  189.          if (Val>255) Val=255; /* limit the output */
  190.          if (Val<0)   Val=0;   /* to the range 0-255 */
  191.          SrcImg->Map[x][y][z]=Val;
  192.         }
  193.       }
  194.     }
  195.   }
  196.  
  197. /**************************************|****************************************
  198. Routine   : T_AbsorbGrey3D
  199. Input  par: BitMap3D *SrcImg  (3d image to be absorbed)
  200.             unsigned char Par (absorbtion parameter)
  201. Output par: none
  202. Function  : Converts a 3d image to a homogeneous block of level Par.
  203. ***************************************|***************************************/
  204.  
  205.  void T_AbsorbGrey3D(BitMap3D *SrcImg, unsigned char Par)
  206.   {
  207.    register unsigned int x,y,z;
  208.    const unsigned int Sizex=SrcImg->XSize;
  209.    const unsigned int Sizey=SrcImg->YSize;
  210.    const unsigned int Sizez=SrcImg->ZSize;
  211.    
  212.    for(x=0;x<Sizex;x++)      
  213.    for(y=0;y<Sizey;y++)
  214.    for(z=0;z<Sizez;z++)
  215.    SrcImg->Map[x][y][z]=Par;
  216.   }
  217.  
  218. /**************************************|****************************************
  219. Routine   : Sample3D
  220. Input  par: BitMap3D *SrcImg (image to sample from)
  221.             BitMap3D *DstImg (destination image)
  222.             int XPos,int YPos,int ZPos (the position in the source image)
  223. Output par: none
  224. Function  : Takes a 3d image 
  225. ***************************************|***************************************/
  226.  
  227.  void Sample3D(BitMap3D *SrcImg,BitMap3D *DstImg,int XPos,int YPos,int ZPos)
  228.   {
  229.    register unsigned int x,y,z,i,j,k;
  230.    register unsigned int Sum;
  231.    const unsigned int Sizex=DstImg->XSize<<1;
  232.    const unsigned int Sizey=DstImg->YSize<<1;
  233.    const unsigned int Sizez=DstImg->ZSize<<1;
  234.    
  235.    for(x=0;x<Sizex;x+=2)      
  236.     {
  237.      for(y=0;y<Sizey;y+=2)        
  238.      for(z=0;z<Sizez;z+=2)        
  239.       {
  240.        Sum=0;
  241.        for(i=0;i<2;i++)          
  242.        for(j=0;j<2;j++)
  243.        for(k=0;k<2;k++) Sum+=SrcImg->Map[XPos+x+i][YPos+y+j][ZPos+z+k];
  244.        
  245.        DstImg->Map[x>>1][y>>1][z>>1]=Sum>>3;
  246.       }
  247.     }
  248.   }
  249.  
  250. /**************************************|****************************************
  251. Routine   : *Expand23D
  252. Input  par: BitMap3D *SrcImg (image to be expanded)
  253. Output par: BitMap3D * (pointer to expanded image)
  254. Function  : Takes an image and expand it with a factor two.
  255. ***************************************|***************************************/
  256.  
  257.  BitMap3D *Expand23D(BitMap3D *SrcImg)
  258.   {
  259.    BitMap3D *DstImg=GimmeABitMap3D((SrcImg->XSize)<<1,(SrcImg->YSize)<<1,
  260.                          (SrcImg->ZSize)<<1,SrcImg->ImgType);
  261.    register unsigned int x,y,z;
  262.    const unsigned int Sizex=DstImg->XSize;
  263.    const unsigned int Sizey=DstImg->YSize;
  264.    const unsigned int Sizez=DstImg->ZSize;
  265.  
  266.    for(x=0;x<Sizex;x++)    
  267.    for(y=0;y<Sizey;y++) 
  268.    for(z=0;z<Sizez;z++) DstImg->Map[x][y][z]=SrcImg->Map[x>>1][y>>1][z>>1];
  269.    
  270.    FreeMeABitMap3D(SrcImg);
  271.    return DstImg;
  272.   }
  273.  
  274. /**************************************|****************************************
  275. Routine   : PSNR3D
  276. Input  par: BitMap3D *ImgA,BitMap3D *ImgB (images to be comparred)
  277. Output par: float (PSNR value)
  278. Function  : Calculates the PSNR value of two 3d images.
  279. ***************************************|***************************************/
  280.  
  281.  float PSNR3D(BitMap3D *ImgA,BitMap3D *ImgB)
  282.   {
  283.    float ret;
  284.    unsigned long mse=0;
  285.    
  286.    mse=dl23D(ImgA,0,0,0,ImgB);
  287.    ret=10.0*log10((float)(255*255)/(float)mse*(float)(ImgB->XSize*ImgB->YSize*ImgB->ZSize));
  288.    return ret;
  289.   }
  290.  
  291. /**************************************|****************************************
  292. Routine   : dl23D
  293. Input  par: BitMap3D *ImgA (first image)
  294.             int AXPos,int AYPos, int AZPos (postion in first image)
  295.             BitMap3D *ImgB (second image)
  296. Output par: unsigned long
  297. Function  : Calculates the dl2 distance between two images.
  298.             Notice: no division with volume!
  299. ***************************************|***************************************/
  300.  
  301.  unsigned long dl23D(BitMap3D *ImgA,int AXPos,int AYPos,int AZPos,BitMap3D *ImgB)
  302.   {
  303.    register unsigned int x,y,z;
  304.    register unsigned long Distortion=0;
  305.    register int tmp;
  306.    const unsigned int Sizex=ImgB->XSize;
  307.    const unsigned int Sizey=ImgB->YSize;
  308.    const unsigned int Sizez=ImgB->ZSize;
  309.  
  310.    for(x=0;x<Sizex;x++)    
  311.    for(y=0;y<Sizey;y++)      
  312.    for(z=0;z<Sizez;z++)
  313.     {
  314.      tmp=ImgA->Map[AXPos+x][AYPos+y][AZPos+z]-ImgB->Map[x][y][z];
  315.      Distortion +=tmp*tmp;
  316.     }
  317.    /* no div with volume ! */
  318.    
  319.    return Distortion;
  320.   }
  321.  
  322. /**************************************|****************************************
  323. Routine   : Isometri3D
  324. Input  par: BitMap3D *SrcImg (bitmap to be rotated)
  325.             BitMap3D *DstImg (output from manipulation)
  326.             int type (the isometri type: 1-8)
  327. Output par: none.
  328. Function  : Isometric transformaition of a 3d image. 
  329. ***************************************|***************************************/
  330.  
  331.  void Isometri3D(BitMap3D *SrcImg,BitMap3D *DstImg, int type)
  332.   {
  333.    register unsigned int z,y,x;
  334.    const unsigned int Sizex=SrcImg->XSize;
  335.    const unsigned int Sizey=SrcImg->YSize;
  336.    const unsigned int Sizez=SrcImg->ZSize;
  337.  
  338.    switch(type)    
  339.     {
  340.      case 1:
  341.      for(x=0;x<Sizex;x++)      
  342.      for(y=0;y<Sizey;y++)
  343.      for(z=0;z<Sizez;z++)
  344.      DstImg->Map[x][y][z]=SrcImg->Map[x][y][z];
  345.      break;
  346.      case 2: 
  347.      for(x=0;x<Sizex;x++)      
  348.      for(y=0;y<Sizey;y++)
  349.      for(z=0;z<Sizez;z++)
  350.      DstImg->Map[x][y][z]=SrcImg->Map[x][Sizey-1-y][z];
  351.      break;
  352.      case 3: 
  353.      for(x=0;x<Sizex;x++)      
  354.      for(y=0;y<Sizey;y++)
  355.      for(z=0;z<Sizez;z++)
  356.      DstImg->Map[x][y][z]=SrcImg->Map[Sizex-1-x][y][z];
  357.      break;
  358.      case 4: 
  359.      for(x=0;x<Sizex;x++)      
  360.      for(y=0;y<Sizey;y++)
  361.      for(z=0;z<Sizez;z++)
  362.      DstImg->Map[x][y][z]=SrcImg->Map[y][x][z];
  363.      break;
  364.      case 5: 
  365.      for(x=0;x<Sizex;x++)      
  366.      for(y=0;y<Sizey;y++)
  367.      for(z=0;z<Sizez;z++)
  368.      DstImg->Map[x][y][z]=SrcImg->Map[Sizex-1-y][Sizey-1-x][z];
  369.      break;
  370.      case 6: 
  371.      for(x=0;x<Sizex;x++)      
  372.      for(y=0;y<Sizey;y++)
  373.      for(z=0;z<Sizez;z++)
  374.      DstImg->Map[x][y][z]=SrcImg->Map[y][Sizey-1-x][z];
  375.      break;
  376.      case 7: 
  377.      for(x=0;x<Sizex;x++)      
  378.      for(y=0;y<Sizey;y++)
  379.      for(z=0;z<Sizez;z++)
  380.      DstImg->Map[x][y][z]=SrcImg->Map[Sizex-1-x][Sizey-1-y][z];
  381.      break;
  382.      case 8:
  383.      for(x=0;x<Sizex;x++)      
  384.      for(y=0;y<Sizey;y++)
  385.      for(z=0;z<Sizez;z++)
  386.      DstImg->Map[x][y][z]=SrcImg->Map[Sizex-1-y][x][z];
  387.      break;
  388.     }
  389.   }
  390.  
  391. /**************************************|****************************************
  392. Routine   : IsoAnddl23D
  393. Input  par: BitMap3D *ImgA (image to be transformed)
  394.             int AXPos, int AYPos, int AZPos (position in original image)
  395.             BitMap3D *ImgB (image to compare to)
  396.             int Size       (size (side length) of comparation volumen)
  397.             int type       (type of isometrie)
  398. Output par: unsigned long  (dl2 distortion)
  399. Function  : A combined version of dl2 and isometri. It takes an image and calcs
  400.             the dl23d distortion to another image with repect to a given 
  401.             isometri tranfromation. This is done to reduce encoding time!
  402.             Notice: no division with volume!
  403. ***************************************|***************************************/
  404.  
  405.  unsigned long IsoAnddl23D(BitMap3D *ImgA, int AXPos, int AYPos, int AZPos,
  406.                            BitMap3D *ImgB, int Size, int type)
  407.   {
  408.    register int x,y,z;
  409.    register unsigned long Distortion=0;
  410.    register int tmp;
  411.    const unsigned int Sizex=ImgB->XSize;
  412.    const unsigned int Sizey=ImgB->YSize;
  413.    const unsigned int Sizez=ImgB->ZSize;
  414.  
  415.    x=Sizex;
  416.    switch(type)    
  417.     {
  418.      case 1:
  419.      while(x--)
  420.       {
  421.        y=Sizey;
  422.        while(y--)
  423.         {
  424.          z=Sizez;
  425.          while(z--)
  426.           {
  427.            tmp=ImgA->Map[AXPos+x][AYPos+y][AZPos+z]-ImgB->Map[x][y][z];
  428.            Distortion+=tmp*tmp;
  429.           }
  430.         }
  431.       }
  432.      break;
  433.      case 2:
  434.      while(x--)      
  435.       {
  436.        y=Sizey;
  437.        while(y--)
  438.         {
  439.          z=Sizez;
  440.          while(z--)
  441.           {
  442.            tmp=ImgA->Map[AXPos+x][AYPos+y][AZPos+z]-ImgB->Map[x][Sizey-1-y][z];
  443.            Distortion+=tmp*tmp;
  444.           }
  445.         }
  446.       }
  447.      break;
  448.      case 3:
  449.      while(x--)      
  450.       {
  451.        y=Sizey;
  452.        while(y--)        
  453.         {
  454.          z=Sizez;
  455.          while(z--)
  456.           {
  457.            tmp=ImgA->Map[AXPos+x][AYPos+y][AZPos+z]-ImgB->Map[Sizex-1-x][y][z];
  458.            Distortion+=tmp*tmp;
  459.           }
  460.         }
  461.       }
  462.      
  463.      break;
  464.      case 4:
  465.      while(x--)      
  466.       {
  467.        y=Sizey;
  468.        while(y--)        
  469.         {
  470.          z=Sizez;
  471.          while(z--)
  472.           {
  473.            tmp=ImgA->Map[AXPos+x][AYPos+y][AZPos+z]-ImgB->Map[y][x][z];
  474.            Distortion+=tmp*tmp;
  475.           }
  476.         }
  477.       }
  478.      break;
  479.      case 5:
  480.      while(x--)      
  481.       {
  482.        y=Sizey;
  483.        while(y--)        
  484.         {
  485.          z=Sizez;
  486.          while(z--)
  487.           {
  488.            tmp=ImgA->Map[AXPos+x][AYPos+y][AZPos+z]-ImgB->Map[Sizex-1-y][Sizey-1-x][z];
  489.            Distortion+=tmp*tmp;
  490.           }
  491.         }
  492.       }
  493.      break;
  494.      case 6:
  495.      while(x--)      
  496.       {
  497.        y=Sizey;
  498.        while(y--)        
  499.         {
  500.          z=Sizez;
  501.          while(z--)
  502.           {
  503.            tmp=ImgA->Map[AXPos+x][AYPos+y][AZPos+z]-ImgB->Map[y][Sizey-1-x][z];
  504.            Distortion+=tmp*tmp;
  505.           }
  506.         }
  507.       }
  508.      break;
  509.      case 7:
  510.      while(x--)      
  511.       {
  512.        y=Sizey;
  513.        while(y--)        
  514.         {
  515.          z=Sizez;
  516.          while(z--)
  517.           {
  518.            tmp=ImgA->Map[AXPos+x][AYPos+y][AZPos+z]-ImgB->Map[Sizex-1-x][Sizey-1-y][z];
  519.            Distortion+=tmp*tmp;
  520.           }
  521.         }
  522.       }
  523.      break;
  524.      case 8:
  525.      while(x--)      
  526.       {
  527.        y=Sizey;
  528.        while(y--)        
  529.         {
  530.          z=Sizez;
  531.          while(z--)
  532.           {
  533.            tmp=ImgA->Map[AXPos+x][AYPos+y][AZPos+z]-ImgB->Map[Sizex-1-y][x][z];
  534.            Distortion+=tmp*tmp;
  535.           }
  536.         }
  537.       }
  538.      break;
  539.     }
  540.    
  541.    return Distortion; /* notice no div with Size*Size*Size! */
  542.   }
  543.  
  544. /**************************************|****************************************
  545. Routine   : MakeRange
  546. Input  par: float p (float to be conveted)
  547.             Parameter *pa (pointer to the parameters)
  548. Output par: unsigned char (output from the quantization)
  549. Function  : Converts a float to an unsigned char according to the range given
  550.             in the parameters. The float is quantizied asymetric.
  551.             Range:  {pa->AMin,pa->AMax} 
  552.             Bits used: pa->ABits
  553. ***************************************|***************************************/
  554.  
  555.  unsigned char MakeRange(float p,Parameter *pa) /* asymetric quant */
  556.   {
  557.    if (p>pa->AMax) p=pa->AMax;
  558.    if (p<pa->AMin) p=pa->AMin;
  559.    return (unsigned char)((p-pa->AMin)/(pa->AMax-pa->AMin)*(float)((1<<pa->ABits)-1)+0.5);
  560.   }
  561.  
  562. /**************************************|****************************************
  563. Routine   : MakeFloat
  564. Input  par: unsigned char conv (bitarray to be converted)
  565.             Parameter *pa (poiter to parameters)
  566. Output par: float (converted integer)
  567. Function  : Converts an unsiged char (or bitarray) to a float. See MakeRange.
  568. ***************************************|***************************************/
  569.  
  570.  float MakeFloat(unsigned char conv,Parameter *pa)
  571.   {
  572.    return (float)((conv)*(pa->AMax-pa->AMin)/(float)((1<<pa->ABits)-1)+pa->AMin);
  573.   }
  574.